package day0423;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author Stringzhua
 * @Date 2024/4/23 13:18
 * description:
 */
public class RemoteControl{
    private Map<String,Command> slots=new HashMap<>();
    public void addCommand(String slotName,Command command){//添加命令
        slots.put(slotName,command);
    }
    public void pressButton(String slotName){//按下按钮的动作
        Command command=slots.get(slotName);
        //判断按钮后面的命令是否为空
        if(command!=null){
            command.execute();
        }else{
            System.out.println("不存在"+slotName+"命令");
        }
    }
}
